<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="module/common.jsp"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="cosmo云工厂">
    <meta name="Keywords" content="cosmo,cosmo云工厂">
    <title>cosmo云工厂</title>
    <link href="${ctxStatic}/cloudfactory/css/basic.css" rel="stylesheet" type="text/css" />
    <link href="${ctxStatic}/cloudfactory/css/main.css" rel="stylesheet" type="text/css" />
        <link href="${ctxStatic}/cloudfactory/css/flex.css" rel="stylesheet" type="text/css" />
    <link href="${ctxStatic}/cloudfactory/css/cloudFoundry.css" rel="stylesheet" type="text/css" />
    <!–[if lt IE9]>
    <script src="${ctxStatic}/cloudfactory/js/html5.js"></script>
    <![endif]–>
</head>

<body>
<div class="sys_warp">
    <!--header开始-->
    <jsp:include page="module/head.jsp" flush="true" />
    <!--header结束,banner开始-->
     <div class="container child_container">
        <div class="sys_width">
            <!--登录-->
            <section class="loginBox">
                <div class="logTitle tx-center">
                    <h3 class="tc-fff">注册</h3>
                </div>
                <div class="logCont bc-fff">
                    <form id="inputForm" modelAttribute="cloudfactoryUser" method="post" autocomplete="off">
                        <div class="ps_r regBox row">
                            <label>请设置您的账号名</label>
                            <input type="text" name="name" id="name" style="width:270px"  required="required" >
                        </div>
                        <div class="ps_r regBox row">
                            <label>请设置您的密码</label>
                            <input type="password" required="required"  name="password" id="psw"  style="width:270px">
                            <i></i>
                        </div>
                        <div class="ps_r regBox row">
                            <label>请再次输入密码</label>
                            <input type="password" required="required"  name="rep-password" id="repPsw"  style="width:270px">
                            <i id="messagepassword" style="padding-left:10px; font-size:10px; color: #ff0000;"></i>
                        </div>
                        <div class="ps_r regBox row">
                            <label>请输入您的手机号</label>
                            <input type="number" required="required"  name="phone" id="phone" style="width:270px">
                            <i id="messagephone" style="padding-left:10px; font-size:10px; color: #ff0000;"></i>
                        </div>
                        <!-- <div class="ps_r regBox row">
                            <label>&emsp;</label>
                            <input class="inputCode" type="text" name="code" placeholder="输入手机验证码" required>
                            <button class="bc-blue tc-fff" type="button" id="getCode">获取验证码</button>
                        </div> -->
                        <div class="ps_r regBox row">
                            <label>邮箱</label>
                            <input type="text" required="required"  name="mail" id="mail"  style="width:270px">
                           
                             <i id="messagemail" style="padding-left:10px; font-size:10px; color: #ff0000;"></i>
                        </div>
                       
                        <div class="ps_r regBox row">
                            <label><input type="checkbox" id="agreess"></label>
                            <p class="tc-yel">我已阅读并同意 <a class="tc-yel" href="###" target="_blank">《COSMO云工厂用户协议》</a>和 <a  class="tc-yel" href="###" target="_blank">《隐私政策声明》</a></p>
                        </div>
                       <button class="tc-fff" onclick="submitbtn()" type="button" id="submit" >同意协议并注册</button>
                    </form>

                </div>
            </section>
        </div>
    </div>
    <!--主体结束,footer开始-->
    <jsp:include page="module/foot.jsp" flush="true" />
    <!--footer结束-->
</div>
</body>
<script type="text/javascript" src="${ctxStatic}/cloudfactory/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/cloudfactory/js/main.js"></script>
<script>


function submitbtn() {
	var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9])|(18[0-9]{1}))+\d{8})$/;
	var emalReg = /^([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$/;
	var name = $("#name").val();
	var psw = $("#psw").val();
	var repPsw = $("#repPsw").val();
	var phone = $("#phone").val();
	var mail = $("#mail").val();
	if(psw != repPsw) {
		$("#messagepassword").html("输入的两次密码不一致");
		$("#messagepassword").show();//显示  
		return ;
	} else {
		$("#messagepassword").hide();
	}
	var result = emalReg.test(mail);
	if (!result) {
		$("#messagemail").html("请输入正确的邮箱地址");
		$("#messagemail").show();//显示  
		return ;
	} else {
		$("#messagemail").hide();
	}
	
	if (phone.length != 11) {
		$("#messagephone").html("手机号位数无效");
		$("#messagephone").show();//显示  
		return ;
	} else {
		$("#messagephone").hide();
	}
	var result = reg.test(phone);
	if (!result) {
		$("#messagephone").html("请输入有效的手机号");
		$("#messagephone").show();//显示  
		return ;
	} else {
		$("#messagephone").hide();
	}
	if(!$("input[type='checkbox']").is(':checked')){
		$("#message").html("请先阅读《COSMO云工厂用户协议》和隐私协议，并确认");
		$("#message").show();//显示  
		return ;
	}
	
	
	$.ajax({
		//几个参数需要注意一下
		type : "GET",//方法类型
		dataType : "json",//预期服务器返回的数据类型
		url : "${ctx}/loginCenter/saveRegister",//url
		data : {
			name:name,
			psw:psw,
			mail:mail,
			phone:phone
		},
		success : function(result) {
			debugger;
			if (result.success == "success") {
				
				alert("注册成功");

				window.location.href = "${ctx}/loginCenter/goIndex?id="+result.id;
			} else {
				alert(result.success);
				return false;
			}
		},
		error : function(result) {
			alert("注册异常");
			return ;
		}
	});
	
	
}
    $(function(){
        indexInit();
        
        
        $("#agreess").on("click",function(){
            var checked = $(this).is(":checked");
            if(checked){
                $("#submit").removeAttr("disabled").addClass("bc-blue");
            }else{
                $("#submit").prop("disabled",true).removeClass("bc-blue");
            }
        });
    });
</script>
</html>